﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var keyValue = $.request("keyValue");
    $(function () {
        initControl();
        $('#myTab a:first').tab('show');
        $("#roleList").treeview({
            height: 300,
            showcheck: true,
            url: "/SystemManage/User/GetRoleList?r=" + Math.random(),
            param: { userId: keyValue }
        });

        $("#dutyList").treeview({
            height: 444,
            showcheck: true,
            url: "/SystemManage/User/GetDutyList?r=" + Math.random(),
            param: { userId: keyValue }
        });

        if (!!keyValue) {
            $.ajax({
                url: "/SystemManage/User/GetFormJson?r=" + Math.random(),
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                    $("#F_UserPassword").val("******").attr('disabled', 'disabled');
                }
            });
        }
    });
    function initControl() {
        $("#F_Gender").bindSelect()
        $("#F_IsAdministrator").bindSelect()
        $("#zt").bindSelect();
        $("#F_OrganizeId").bindSelect({
            url: "/SystemManage/Organize/GetTreeSelectJson?r=" + Math.random(),
        });
        $("#F_DepartmentId").bindSelect({
            url: "/SystemManage/Organize/GetTreeSelectJson?r=" + Math.random(),
        });
    }
    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        var postData = $("#form1").formSerialize();
        postData["roleList"] = String($("#roleList").getCheckedNodes());
        postData["dutyList"] = String($("#dutyList").getCheckedNodes());
        $.submitForm({
            url: "/SystemManage/User/SubmitForm?keyValue=" + keyValue + "&r=" + Math.random(),
            param: postData,
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
</script>
<form id="form1">
    <div class="container" style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
        <ul class="nav nav-tabs" role="tablist" id="myTab">
            <li role="presentation"><a href="#basicInfo" role="tab" data-toggle="tab">基本信息</a></li>
            <li role="presentation"><a href="#userRole" role="tab" data-toggle="tab">用户角色</a></li>
            <li role="presentation"><a href="#userDuty" role="tab" data-toggle="tab">用户岗位</a></li>
        </ul>
        <div class="tab-content">
            <div role="tabpanel" class="tab-pane fade in active" style="padding-top: 20px; margin-right: 30px;" id="basicInfo">
                <table class="form">
                    <tr>
                        <th class="formTitle">账户</th>
                        <td class="formValue">
                            <input id="F_Account" name="F_Account" type="text" class="form-control required" placeholder="请输入账户" />
                        </td>
                        <th class="formTitle">密码</th>
                        <td class="formValue">
                            <input id="F_UserPassword" name="F_UserPassword" type="password" class="form-control required" placeholder="请输入密码" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">公司</th>
                        <td class="formValue">
                            <select id="F_OrganizeId" name="F_OrganizeId" class="form-control required"></select>
                        </td>
                        <th class="formTitle">部门</th>
                        <td class="formValue">
                            <select id="F_DepartmentId" name="F_DepartmentId" class="form-control required">
                                <option value="">==请选择==</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">姓名</th>
                        <td class="formValue">
                            <input id="F_RealName" name="F_RealName" type="text" class="form-control required" placeholder="请输入姓名" />
                        </td>
                        <th class="formTitle">性别</th>
                        <td class="formValue">
                            <select id="F_Gender" name="F_Gender" class="form-control required">
                                <option value="true">男</option>
                                <option value="false">女</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">手机</th>
                        <td class="formValue">
                            <input id="F_MobilePhone" name="F_MobilePhone" type="text" class="form-control mobilephone" />
                        </td>
                        <th class="formTitle">生日</th>
                        <td class="formValue">
                            <input id="F_Birthday" name="F_Birthday" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">微信</th>
                        <td class="formValue">
                            <input id="F_WeChat" name="F_WeChat" type="text" class="form-control" />
                        </td>
                        <th class="formTitle">邮箱</th>
                        <td class="formValue">
                            <input id="F_Email" name="F_Email" type="text" class="form-control email" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">类型</th>
                        <td class="formValue">
                            <select id="F_IsAdministrator" name="F_IsAdministrator" class="form-control">
                                <option value="false">普通用户</option>
                                <option value="true">系统管理员</option>
                            </select>
                        </td>
                        <th class="formTitle">允许登录</th>
                        <td class="formValue">
                            <select id="zt" name="zt" class="form-control">
                                <option value="1">是</option>
                                <option value="0">否</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle" valign="top" style="padding-top: 5px;">
                            备注
                        </th>
                        <td class="formValue" colspan="3">
                            <textarea id="F_Description" name="F_Description" class="form-control" style="height: 60px;"></textarea>
                        </td>
                    </tr>
                </table>
            </div>
            <div role="tabpanel" class="tab-pane fade in" style="padding-top: 20px; margin-right: 30px;" id="userRole">
                <div id="roleList"></div>
            </div>
            <div role="tabpanel" class="tab-pane fade in" style="padding-top: 20px; margin-right: 30px;" id="userDuty">
                <div id="dutyList"></div>
            </div>
        </div>
    </div>
</form>
